<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="/assets/layui/css/layui.css">
    <!-- <link rel="stylesheet" href="/assets/css/login.css"> -->
    <style>
        body{
            background-color: skyblue;
        }
        h1{
            text-align: center;
            margin-top: 10%;
        }
        #loginForm{
            text-align: center;
            font-size: 20px;
        }
        #username{
            width: 200px;
            height: 40px;
            margin: 20px 0;
        }
        #password{
            width: 200px;
            height: 40px;
            margin: 20px 0;
        }
        #loginBtn{
            width: 250px;
            height: 40px;
            background-color: blue;
            color:white;
            border-radius: 4px;
            border: 0;
        }
    </style>
</head>
<body>
    <div class="login">
        <h1>小罗博客管理系统</h1>
        <form method="post"  id="loginForm">
            用户名<input type="text" id="username" name="username" placeholder="请输入用户名" /><br>
            密&nbsp;&nbsp;&nbsp;码<input type="password"id="password" name="password" placeholder="请输入密码"  /><br>
            <button type="submit" id="loginBtn" class="btn btn-primary btn-block btn-large">登录</button>
        </form>
    </div>
</body>
<script src="/assets/js/jquery.min.js"></script>
<script src="/assets/layui/layui.js"></script>
<script>
    $("#loginBtn").on('click',()=>{
        const data = $("#loginForm").serialize()
        console.log(data)
        $.post('/userLogin',data).then(res=>{
            const {code,message} = res;
            if(code === 0){
                location.href = '/'
            }else{
                layer.msg(message)
            }
        })
        
        
        return false;
    })
</script>
</html>